package com.atguigu.enu;

enum Season{
    //1.提供当前枚举类的多个对象,多个对象之间用逗号隔开,末尾对象分号结束
    SPRING("春天","万物生长"),
    SUMMER("夏天","火热炎炎"),
    AUTUMN("秋天","火红枫叶"),
    WINTER("冬天","万物寂寥");
    //2.声明Season类的对象的属性 :需要用private final来进行修饰
    private final String seasonName;
    private final String seasonDesc;
    //3.私有化类的构造器,并给对象属性赋值
    private Season(String seasonName, String seasonDesc){
        this.seasonDesc=seasonDesc;
        this.seasonName=seasonName;
    }
}

public class SeasonTest2 {
    public static void main(String[] args) {
        Season summer=Season.SUMMER;
        System.out.println(summer); //打印值为SUMMER
        System.out.println(Season.class.getSuperclass()); //继承于java.lang.Enum类
        //values()方法,返回枚举类型的对象数组
        for (Season value : Season.values()) {
            System.out.print(value+" ");  //输出SPRING SUMMER AUTUMN WINTER
        }
        System.out.println();
        //valueOf(String objName) :根据提供的objName，返回与objName相同名的对象
        Season winter=Season.valueOf("WINTER");
        System.out.println(winter);
    }
}
